<template>
    <div class="Detial body">
        <div class="lef">
            <div class="content" v-if="JSON.stringify(info) != '{}'">
                <div class="co_head">
                    <img src="../assets/img/dingweixiao.png" alt="" />
                    <span @click="$router.push('/')">首页</span>
                    <img src="../assets/img/xiangyou.png" alt="" />
                    <span @click="$router.push('/')">资讯</span>
                    <img src="../assets/img/xiangyou.png" alt="" />
                    <span
                        @click="$router.push(`/?chanl=${channel.channel_id}`)"
                        >{{ channel.channel_name }}</span
                    >
                    <img src="../assets/img/xiangyou.png" alt="" />
                    <span>正文</span>
                </div>
                <h1 class="co_title">
                    <span>{{ info.title }}</span>
                </h1>
                <h2 class="co_tools">
                    <h3>
                        <h6 v-if="info.user">
                            <img :src="info.user.avatar_url" alt="" />
                        </h6>
                        <div class="useraaa">
                            <span v-if="info.user">{{
                                info.user.nickname
                            }}</span>
                            <i>{{ info.user.identity_name }}</i>
                        </div>

                        <h5 v-if="false">
                            <img src="../assets/img/i_img_white_+.png" alt="" />
                            <b>关注</b>
                        </h5>
                        <span class="tuijian" v-if="info.is_recommend"
                            ><i>推荐</i></span
                        >
                        <span
                            class="statuddd"
                            v-if="info.is_original && !info.is_first_publish"
                            ><i>原创</i></span
                        >
                        <span class="statuddd" v-if="info.is_first_publish"
                            ><i>首发</i></span
                        >

                        <!-- <span v-if="info.is_original"><i>原创</i></span>
                        <span v-if="info.is_original"><i>推荐</i></span>
                        <span v-if="info.is_original"><i>首发</i></span> -->
                    </h3>
                    <h4>
                        <p>{{ info.publish_time_desc }}</p>
                        <ul>
                            <li>
                                <img
                                    src="../assets/img/i_icon_chakan.png"
                                    alt=""
                                />
                                <span>{{ info.view_count }}</span>
                            </li>
                            <li>
                                <img
                                    style="margin-top: 2px"
                                    src="../assets/img/i_icon_pinglun.png"
                                    alt=""
                                />
                                <span>{{ info.comment_count }}</span>
                            </li>
                            <!-- <li>
                                <img
                                    src="../assets/img/fenxiangzhuanfa.png"
                                    alt=""
                                />
                                <span>{{ info.share_count }}</span>
                            </li>
                            <li>
                                <img src="../assets/img/guanzhu.png" alt="" />
                                <span>{{ info.favorite_count }}</span>
                            </li> -->
                        </ul>
                    </h4>
                </h2>

                <h3 class="co_zhaiy">
                    <p>{{ info.article_desc }}</p>
                </h3>

                <h4 class="co_box" v-html="info.content"></h4>

                <ol class="li_tag" v-if="info.article_key_words">
                    <i
                        v-for="(itemr, index) in info.article_key_words.split(
                            ' '
                        )"
                        :key="index"
                        >{{ itemr }}</i
                    >
                </ol>
            </div>
            <Disscuss :ifmargin="true" :id="info.id" />

            <div class="hp_title">
                <h1>相关资讯</h1>
            </div>

            <List
                :type="'detail'"
                :detialId="this.$router.history.current.query.id"
                :detialChannelId="info.channel_id"
                v-if="JSON.stringify(info) != '{}'"
            />
        </div>
        <div class="rig">
            <Popularity />
            <Special />
            <Active />
        </div>
    </div>
</template>

<script>
import Popularity from '../components/Popularity';
import Special from '../components/Special';
import Active from '../components/Active';
import Disscuss from '../components/Disscuss';
import List from '../components/List';
import { axiosGet } from '../server/axios';
export default {
    name: 'DeTial',
    components: {
        Popularity,
        Special,
        Active,
        Disscuss,
        List,
    },
    data() {
        return {
            info: {},
            channel: {
                channel_name: '',
                channel_id: '',
            },
        };
    },
    mounted() {
        this.getDetial();
    },
    watch: {
        $route: 'reloadDetail',
    },
    methods: {
        reloadDetail() {
            this.getDetial();
        },
        getDetial() {
            axiosGet(
                `/api/articles/${this.$router.history.current.query.id}`,
                {},
                (res) => {
                    console.log(res.data);
                    if (res.code != 'ok') {
                        this.$notify({
                            title: '警告',
                            message: res.msg,
                            type: 'warning',
                        });
                    }
                    this.info = res.data;
                    this.channel.channel_name = res.data.channel_name;
                    this.channel.channel_id = res.data.channel_id;
                }
            );
        },
    },
};
</script>

<style scoped lang="scss">
.li_tag {
    overflow: hidden;
    margin-top: 16px;
    i {
        height: 20px;
        background: #f5f5f5;
        border-radius: 4px;
        font-size: 12px;
        font-family: Source Han Sans SC VF;
        font-weight: 400;
        color: #a7a7a7;
        padding: 4px 9px;
        float: left;
        margin-right: 4px;
        margin-bottom: 5px;
    }
}
.Detial {
    width: 1200px;
    margin: 20px auto 50px;
    overflow: hidden;
}
.lef {
    float: left;
    width: 770px;
    overflow: hidden;
    box-shadow: 0 0 8px 4px #f5f5f5;
    margin-bottom: 8px;
}
.rig {
    width: 410px;
    float: right;
    overflow: hidden;
    box-shadow: 0 0 8px 4px #f5f5f5;
    margin-bottom: 8px;
}

.content {
    padding: 0 20px;
    overflow: hidden;

    .co_imgbox {
        overflow: hidden;
        margin-bottom: 15px;

        img {
            width: 100%;
        }
    }

    .co_tag {
        display: flex;
        justify-content: space-between;
        align-items: center;

        ul {
            li {
                float: left;
                display: flex;
                justify-content: center;
                align-items: center;
                width: 42px;
                height: 20px;
                background: #f5f5f5;
                border-radius: 4px;
                margin-right: 4px;
                font-size: 12px;
                font-family: Source Han Sans SC VF;
                font-weight: 400;
                color: #a7a7a7;
            }
        }

        span {
            font-size: 13px;
            font-family: Source Han Sans SC VF;
            font-weight: 400;
            color: #787878;
            line-height: 18px;
        }
    }

    .co_head {
        height: 58px;
        display: flex;
        align-items: center;
        font-size: 14px;
        font-family: Source Han Sans SC VF;
        font-weight: 400;
        color: #787878;
        line-height: 18px;
        cursor: pointer;

        span {
            margin: 0 3px;
        }

        img {
            margin-top: 2px;
        }
    }

    .co_title {
        font-size: 26px;
        font-family: Source Han Sans SC VF;
        font-weight: 500;
        color: #262626;
        line-height: 36px;
        display: flex;
        justify-content: flex-start;
        align-items: flex-start;
        position: relative;

        .spanact {
            text-indent: 2em;
        }

        i {
            width: 40px;
            height: 20px;
            background: linear-gradient(-90deg, #fd6403 0%, #e60012 100%);
            border-radius: 4px;
            font-size: 12px;
            font-family: Source Han Sans SC VF;
            font-weight: 400;
            color: #ffffff;
            display: flex;
            justify-content: center;
            align-items: center;
            margin-right: 2px;
            position: absolute;
            left: 5px;
            top: 7px;
        }
    }
    .co_tools {
        display: flex;
        justify-content: space-between;
        align-items: center;
        height: 80px;

        .tuijian {
            width: 40px;
            height: 20px;
            background: linear-gradient(-90deg, #fd6403 0%, #e60012 100%);
            border-radius: 4px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 12px;
            font-family: Source Han Sans SC VF;
            font-weight: 400;
            color: #ffffff;
            border: 0;
            padding: 0;

            i {
                color: #fff;
            }
        }

        .statuddd {
            background: #f4f4f5;
            border: 1px solid #cbcccf;
            border-radius: 4px;
            padding: 1.5px 8.5px;
            margin-right: 5px;
            font-size: 12px;
        }

        h3 {
            display: flex;
            justify-content: flex-start;
            align-items: center;

            h6 {
                width: 35px;
                height: 35px;
                overflow: hidden;
                border-radius: 50%;

                img {
                    width: 100%;
                }
            }

            .useraaa {
                display: flex;
                flex-direction: column;

                i {
                    margin: 0 12px 0 8px;
                }
            }

            span {
                font-size: 16px;
                font-family: Source Han Sans SC VF;
                font-weight: 400;
                color: #262626;
                margin: 0 12px 0 8px;
            }

            i {
                font-size: 12px;
                font-family: Source Han Sans SC VF;
                font-weight: 400;
                color: #787878;
            }

            h5 {
                width: 61px;
                height: 31px;
                background: #ffffff;
                border: 1px solid #262626;
                border-radius: 4px;
                display: flex;
                justify-content: center;
                align-items: center;
                cursor: pointer;
                margin-left: 10px;

                img {
                    margin-right: 4px;
                }
                b {
                    font-size: 14px;
                    font-family: Source Han Sans SC VF;
                    font-weight: 400;
                    color: #262626;
                }
            }
        }

        h4 {
            display: flex;
            justify-content: flex-start;
            align-items: center;
            font-size: 14px;
            font-family: Source Han Sans SC VF;
            font-weight: 400;
            color: #a7a7a7;

            p {
                margin-right: 19px;
            }

            ul {
                li {
                    float: left;
                    margin-left: 9px;
                    display: flex;
                    justify-content: center;
                    align-items: center;
                    font-size: 13px;
                    font-family: Source Han Sans SC VF;
                    font-weight: 400;
                    color: #a7a7a7;
                    img {
                        margin-right: 2px;
                    }
                }
            }
        }
    }
    .co_zhaiy {
        background: #fbfbfb;
        border: 1px solid #f2f2f2;
        border-radius: 4px;
        padding: 0 20px;
        display: flex;
        align-items: flex-start;

        span {
            float: left;
            display: flex;
            align-items: center;
            justify-content: center;
            width: 41px;
            height: 21px;
            background: #f4f4f5;
            border: 1px solid #cbcccf;
            border-radius: 4px;
            font-size: 12px;
            font-family: Source Han Sans SC VF;
            font-weight: 400;
            color: #787878;
            margin-top: 10px;
        }

        p {
            font-size: 14px;
            font-family: Source Han Sans SC VF;
            font-weight: 400;
            color: #787878;
            margin-left: 10px;
            /* width: 603px; */
            line-height: 20px;
            padding: 10px 0;
        }
    }
    .co_box {
        padding: 20px 0;
        font-size: 16px;
        font-family: Source Han Sans SC VF;
        font-weight: 400;
        color: #262626;
        line-height: 30px;
    }
    .cd_tag {
        padding: 0 24px;
        li {
            float: left;
            width: 42px;
            height: 20px;
            background: #f5f5f5;
            border-radius: 4px;
            font-size: 12px;
            font-family: Source Han Sans SC VF;
            font-weight: 400;
            color: #a7a7a7;
            display: flex;
            justify-content: center;
            align-items: center;
            margin: 0 3px;
        }
    }
    .co_ztcon {
        font-size: 14px;
        font-family: Source Han Sans SC VF;
        font-weight: 400;
        color: #787878;
        line-height: 28px;
        padding: 10px 0;
    }
    .co_showmore {
        font-size: 14px;
        font-family: Source Han Sans SC VF;
        font-weight: 400;
        color: #262626;
        margin: 5px 0;
        cursor: pointer;
    }
}

.li_zhuanti {
    height: 60px;
    background: #fafafa;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;

    dl {
        display: flex;
        justify-content: flex-start;
        align-items: center;

        dt {
            font-size: 22px;
            font-family: Source Han Sans SC VF;
            font-weight: 400;
            color: #262626;
            margin-left: 4px;
        }
    }

    ul {
        display: flex;
        justify-content: flex-start;
        align-items: center;
        font-size: 14px;
        font-family: Source Han Sans SC VF;
        font-weight: 400;
        color: #787878;

        div {
            width: 2px;
            height: 14px;
            background: #787878;
            margin: 0 14px;
        }

        li {
            cursor: pointer;
            img {
                margin-left: 3px;
            }
        }
    }
}

.zt_detail {
    font-size: 14px;
    font-family: Source Han Sans SC VF;
    font-weight: 400;
    color: #787878;
    line-height: 28px;
    margin-top: 10px;
}
</style>
